import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '标题',
    align: "center",
    dataIndex: 'title'
  },
  {
    title: '价格',
    align: "center",
    dataIndex: 'price'
  },
  {
    title: '天数',
    align: "center",
    dataIndex: 'daysNumber'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'start',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [{ text: '是', value: '1' }, { text: '否', value: '0' }])
    },
  },
  {
    title: '展示',
    align: "center",
    dataIndex: 'isShow',
    customRender: ({ text }) => {
      return render.renderSwitch(text, [{ text: '是', value: '1' }, { text: '否', value: '0' }])
    },
  },
  {
    title: '编码',
    align: "center",
    dataIndex: 'code'
  },
  {
    title: '排序',
    align: "center",
    sorter: true,
    dataIndex: 'sort'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "标题",
    field: 'title',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "状态",
    field: 'start',
    component: 'JSwitch',
    componentProps: {
      query: true,
      options: [1, 0]
    },
    //colProps: {span: 6},
  },
  {
    label: "展示",
    field: 'isShow',
    component: 'JSwitch',
    componentProps: {
      query: true,
      options: [1, 0]
    },
    //colProps: {span: 6},
  },
  {
    label: "编码",
    field: 'code',
    component: 'Input',
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '标题',
    field: 'title',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入标题!' },
      ];
    },
  },
  {
    label: '价格',
    field: 'price',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入价格!' },
      ];
    },
  },
  {
    label: '天数',
    field: 'daysNumber',
    component: 'InputNumber',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入天数!' },
      ];
    },
  },
  {
    label: '状态',
    field: 'start',
    component: 'JSwitch',
    componentProps: {
      options: [1, 0]
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入状态!' },
      ];
    },
  },
  {
    label: '展示',
    field: 'isShow',
    component: 'JSwitch',
    componentProps: {
      options: [1, 0]
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入展示!' },
      ];
    },
  },
  {
    label: '编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '排序',
    field: 'sort',
    component: 'InputNumber',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  title: { title: '标题', order: 0, view: 'text', type: 'string', },
  price: { title: '价格', order: 1, view: 'number', type: 'number', },
  daysNumber: { title: '天数', order: 2, view: 'number', type: 'number', },
  start: { title: '状态', order: 3, view: 'switch', type: 'string', },
  isShow: { title: '展示', order: 4, view: 'switch', type: 'string', },
  code: { title: '编码', order: 5, view: 'text', type: 'string', },
  sort: { title: '排序', order: 6, view: 'number', type: 'number', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}